package cn.edu.zafu.bigdata.x.bd121.course;

/**
 * 课程DTO类
 * 课程的授课时间和授课教师是一对多关系，因此课程DTO类中不包含授课时间信息
 * 课程的选课学生是多对多关系，因此课程DTO类中不包含选课学生信息
 *
 * @author 202211090121
 */
public class Course {

    /**
     * 课程ID(主键)
     */
    private int id;

    /**
     * 课程名称
     */
    private String name;

    /**
     * 任课教师id
     */
    private int teacherId;

    /**
     * 课程学分
     */
    private int credit;

    /**
     * 课程描述
     */
    private String description;
//region
    //get和set方法由idea自动生成

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getTeacherId() {
        return teacherId;
    }

    public void setTeacherId(int teacherId) {
        this.teacherId = teacherId;
    }

    public int getCredit() {
        return credit;
    }

    public void setCredit(int credit) {
        this.credit = credit;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }
    //endregion

    @Override
    public String toString() {
        return "Course{" + "id=" + id + ", name='" + name + '\'' + ", teacherId=" + teacherId + ", credit=" + credit + ", description='" + description + '\'' + '}';
    }

    /**
     * 按作业要求，额外增加print方法
     */
    public boolean printCourse() {
        try {
            System.out.println(this.toString());
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("打印课程信息失败！");
            return false;
        }
    }

    /**
     * 按作业要求，额外增加构造方法
     */
    public Course(int id, String name, int teacherId, int credit, String description) {
        this.id = id;
        this.name = name;
        this.teacherId = teacherId;
        this.credit = credit;
        this.description = description;
    }
}
